import './assets/main.css'

import { createApp } from 'vue'
import router from "@/router/router"
import { createPinia } from "pinia"
import App from './App.vue'

// 创建app
const app = createApp(App)
let pinia = createPinia()
// 加载路由
app.use(router)
app.use(pinia)


import News from './views/01news/News.vue'
// 注册全局通用组件
app.component('News', News)
// 注册全局通用变量，等同于vue2的Vue.prototype.变量名 = 变量值
app.config.globalProperties.moment = { msg: '兰陵王' }
// 定义全局变量时，都要声明此变量，不然其他页面的TS无法类型推断出此变量
declare module 'vue' {
  interface ComponentCustomProperties {
    moment: { [key: string]: any }
  }
}
// 自定义指令
app.directive('beauty', (element, { value }) => {
  element.innerText += value
  element.style.color = 'green'
})

// 挂载在元素上
app.mount('#app')
